#include "gtkcssiconthemevalueprivate.h"
#include "gtkcssrgbavalueprivate.h"
#include "gtksettingsprivate.h"
+#include "gtksnapshot.h"
#include "gtkstyleproviderprivate.h"
#include "gtkiconthemeprivate.h"
}
static void
-gtk_css_image_icon_theme_draw (GtkCssImage *image,
- cairo_t *cr,
- double width,
- double height)
+gtk_css_image_icon_theme_snapshot (GtkCssImage *image,
+ GtkSnapshot *snapshot,
+ double width,
+ double height)
{
GtkCssImageIconTheme *icon_theme = GTK_CSS_IMAGE_ICON_THEME (image);
GError *error = NULL;
GtkIconInfo *icon_info;
+ GskTexture *texture;
GdkPixbuf *pixbuf;
+ double texture_width, texture_height;
gint size;
size = floor (MIN (width, height));
return;
}
- cairo_translate (cr, width / 2.0, height / 2.0);
- cairo_scale (cr, 1.0 / icon_theme->scale, 1.0 / icon_theme->scale);
- gdk_cairo_set_source_pixbuf (cr,
- pixbuf,
- - gdk_pixbuf_get_width (pixbuf) / 2.0,
- - gdk_pixbuf_get_height (pixbuf) / 2.0);
- cairo_paint (cr);
-
+ texture = gsk_texture_new_for_pixbuf (pixbuf);
+ texture_width = (double) gdk_pixbuf_get_width (pixbuf) / icon_theme->scale;
+ texture_height = (double) gdk_pixbuf_get_height (pixbuf) / icon_theme->scale;
+
+ gtk_snapshot_append_texture_node (snapshot,
+ texture,
+ &GRAPHENE_RECT_INIT(
+ (width - texture_width) / 2.0,
+ (height - texture_height) / 2.0,
+ texture_width,
+ texture_height
+ ),
+ "CssImageIconTheme<%s@%d>", icon_theme->name, icon_theme->scale);
+
+ gsk_texture_unref (texture);
g_object_unref (pixbuf);
g_object_unref (icon_info);
}
GObjectClass *object_class = G_OBJECT_CLASS (klass);
image_class->get_aspect_ratio = gtk_css_image_icon_theme_get_aspect_ratio;
- image_class->draw = gtk_css_image_icon_theme_draw;
+ image_class->snapshot = gtk_css_image_icon_theme_snapshot;
image_class->parse = gtk_css_image_icon_theme_parse;
image_class->print = gtk_css_image_icon_theme_print;
image_class->compute = gtk_css_image_icon_theme_compute;
}
static void
-gtk_css_image_scaled_draw (GtkCssImage *image,
- cairo_t *cr,
- double width,
- double height)
+gtk_css_image_scaled_snapshot (GtkCssImage *image,
+ GtkSnapshot *snapshot,
+ double width,
+ double height)
{
GtkCssImageScaled *scaled = GTK_CSS_IMAGE_SCALED (image);
- _gtk_css_image_draw (scaled->images[scaled->scale - 1], cr, width, height);
+ gtk_css_image_snapshot (scaled->images[scaled->scale - 1], snapshot, width, height);
}
static void
image_class->get_width = gtk_css_image_scaled_get_width;
image_class->get_height = gtk_css_image_scaled_get_height;
image_class->get_aspect_ratio = gtk_css_image_scaled_get_aspect_ratio;
- image_class->draw = gtk_css_image_scaled_draw;
+ image_class->snapshot = gtk_css_image_scaled_snapshot;
image_class->parse = gtk_css_image_scaled_parse;
image_class->compute = gtk_css_image_scaled_compute;
image_class->print = gtk_css_image_scaled_print;
}
static void
-gtk_css_image_url_draw (GtkCssImage *image,
- cairo_t *cr,
- double width,
- double height)
+gtk_css_image_url_snapshot (GtkCssImage *image,
+ GtkSnapshot *snapshot,
+ double width,
+ double height)
{
GtkCssImageUrl *url = GTK_CSS_IMAGE_URL (image);
- _gtk_css_image_draw (gtk_css_image_url_load_image (url, NULL), cr, width, height);
+ gtk_css_image_snapshot (gtk_css_image_url_load_image (url, NULL), snapshot, width, height);
}
static GtkCssImage *
image_class->get_height = gtk_css_image_url_get_height;
image_class->get_aspect_ratio = gtk_css_image_url_get_aspect_ratio;
image_class->compute = gtk_css_image_url_compute;
- image_class->draw = gtk_css_image_url_draw;
+ image_class->snapshot = gtk_css_image_url_snapshot;
image_class->parse = gtk_css_image_url_parse;
image_class->print = gtk_css_image_url_print;